// Copyright 1992-2014, 2020 by Jon Dart. All Rights Reserved.

#include "bhash.h"
#include "bitboard.h"

const CACHE_ALIGN hash_t hash_codes[64][16] =
        {{0x09fa022008550102ULL, 0x731a13283289375bULL, 0x779807be7146f3b3ULL, 0x11be7d2b0a90b21bULL,
        0x6d1e3613c3afd02aULL, 0x08703d506d38f5d3ULL, 0x236160dccfecd6f3ULL, 0x3fdd4ce299a99a73ULL,
        0x7a931066671db88cULL, 0x5ccc60267d79ab1fULL, 0x19cc51ab43de5890ULL, 0x7c51579929b16c2eULL,
        0x2cea51be009fa589ULL, 0x0043567a627644c9ULL, 0x349b486a479a9460ULL, 0x7ff12288554bce2bULL}, 
        {0x1cb876160d693d68ULL, 0x3111310d6800fb7eULL, 0x0cd538ecf9411211ULL, 0x5cf9051b3232675aULL,
        0x27167d3be3c23f36ULL, 0x361243168876bce7ULL, 0x29440d197b752109ULL, 0x21891d72b31d4098ULL,
        0x241f034c0ae0e2a6ULL, 0x49477ebec59e828dULL, 0x3cf6656b553c3740ULL, 0x0a2414e2079d2290ULL,
        0x2d762940a1ce36f2ULL, 0x125721a5928dbbb7ULL, 0x75c02971d3de552bULL, 0x44313472fbfdf49dULL}, 
        {0x74be4d5fb74b82bcULL, 0x310c315b2c7ea349ULL, 0x5ab6684f63c6628fULL, 0x407e495e562520a6ULL,
        0x2a1f13c8b5a6a7ebULL, 0x57d247e7ffb8a9a7ULL, 0x3ab4093bfb608f6bULL, 0x15b859973c73f103ULL,
        0x72c83eeab5a07e8bULL, 0x763b3044006eca95ULL, 0x2ad94c0275fcb7d5ULL, 0x72f4284190a4f05aULL,
        0x6f67580ae54f39b2ULL, 0x737d52df149cf512ULL, 0x15061981ecacbad8ULL, 0x22290a334fae497eULL}, 
        {0x52b327c3ebfac15aULL, 0x78f2721a6be9693eULL, 0x5664242d2525e256ULL, 0x1ab30a7bf39f2652ULL,
        0x07e37e813efa1944ULL, 0x4c9836cce0871537ULL, 0x6ddb588ce49d43e7ULL, 0x23d25ed8d28415a7ULL,
        0x69334d068c9dbdd9ULL, 0x3b8f0cbf5d10fbf9ULL, 0x3a9c1db956ae18baULL, 0x07292c3e8140611dULL,
        0x06660ce61500ff05ULL, 0x149d4f30386c8a3fULL, 0x4a9865e46a342575ULL, 0x53401b552e747602ULL}, 
        {0x7b3f790a0ff56b1eULL, 0x32ad455392ab0562ULL, 0x39060ecf342d1513ULL, 0x2e023cfa065a4432ULL,
        0x5607163005df27beULL, 0x174c6eccb9e9db3aULL, 0x1ce112524c9bdec8ULL, 0x373f3ebd92a696f8ULL,
        0x0e0b0b6935964fa9ULL, 0x152b2037892b10fdULL, 0x076806d830611ddbULL, 0x7b2b6f6117677deeULL,
        0x0a1b4a9af34159a5ULL, 0x0aa06fa1c9429620ULL, 0x129c6fe0a125788cULL, 0x74dd1360f6e8a6dcULL}, 
        {0x370b08fb073c7262ULL, 0x2c24710d8eaab137ULL, 0x7fc55e7d052ffdf2ULL, 0x20d209640e8bc198ULL,
        0x2e36079b0df4e254ULL, 0x5ed642f0976653d3ULL, 0x65ee61d6c84a82d8ULL, 0x1f673ece1ab1dfe8ULL,
        0x6bf62bdbd6cb6798ULL, 0x22f76ab5b1e78265ULL, 0x706447a7b7a507a2ULL, 0x676274331091ce60ULL,
        0x162d67eec7f299cfULL, 0x0e6c013917e8b21bULL, 0x2d3b2cbe67ae1429ULL, 0x086a51da85208140ULL}, 
        {0x52bf73603a4e4802ULL, 0x573f2f50cd4d27c2ULL, 0x6bc95d7f8ff8199dULL, 0x7d8a4c4008eb695aULL,
        0x2e16538bde59dc81ULL, 0x6e1e7a3f070658a7ULL, 0x2b2806606d19cf64ULL, 0x0fb3589487fcd7edULL,
        0x119c342315fbb7c0ULL, 0x28db603f83ec4b73ULL, 0x18b9346d218897fcULL, 0x4837713baab55f86ULL,
        0x4a450fac5671913dULL, 0x7cea4501eea4f611ULL, 0x1e9c25c6117fdbd7ULL, 0x734e6a4d38b432e1ULL}, 
        {0x1f0327ff8d2cde5aULL, 0x49e62e243d7ca085ULL, 0x02396a1c47da6d41ULL, 0x3294161672b284caULL,
        0x774f4ec87cac2640ULL, 0x340c4fc1184f42d8ULL, 0x12ba5338d1f8e838ULL, 0x1f893996775feaf8ULL,
        0x11a77e0b16656fbfULL, 0x0ebf68e02d60e3edULL, 0x678e3574239c0f54ULL, 0x7e105101a24bb7f4ULL,
        0x4a0a409ae4a0922cULL, 0x57026fff9b3dfc66ULL, 0x2ee8783f75c82ea3ULL, 0x7ef12440ecbd61f3ULL}, 
        {0x707d6aa06654a546ULL, 0x3e010f924ca0d685ULL, 0x0c3d769d22a37a88ULL, 0x12572b6f4895dcbbULL,
        0x2f8a221a6d0d530eULL, 0x4389727e554beb0aULL, 0x06ca2fa50a576e9eULL, 0x4a52435c0632007eULL,
        0x02bc37597fca41aeULL, 0x608b609d5bec4514ULL, 0x080c4702f4ee3195ULL, 0x4d56320e364be1bdULL,
        0x3d254d8239dc6e57ULL, 0x419d2b3dedfcdffeULL, 0x6a465573e838ef16ULL, 0x58bb7b3cffd0382aULL}, 
        {0x1fd8530daac68f20ULL, 0x117869a1e59e0345ULL, 0x16ff094a95a3409eULL, 0x533b04d108cebb82ULL,
        0x006f4a49b61c72e5ULL, 0x537b057fce7fad61ULL, 0x358116f0ad248362ULL, 0x6f770b6fd44c8272ULL,
        0x7f8561d676695f2aULL, 0x4e2717803cb7eaacULL, 0x695a796048103d2cULL, 0x5e7266e9222b6776ULL,
        0x4f3d5d2a980675faULL, 0x05a113c330a8363dULL, 0x20df02a840fe803eULL, 0x12141ec84e0660b8ULL}, 
        {0x09ba4d0dbe010dc4ULL, 0x4633465a78dfdfc7ULL, 0x73a43c6b97a9432fULL, 0x0fa84ec7b014e9f1ULL,
        0x17a5181cddf91641ULL, 0x3ecc1fcb10f46180ULL, 0x11061862d0cfc7cfULL, 0x525e5b56fd055b47ULL,
        0x26aa534aa1017a4eULL, 0x2b7b51907c68ccfaULL, 0x3ea270d6550ff602ULL, 0x3dca761aa5e45131ULL,
        0x2ffb6a5ac97d7bcfULL, 0x0ff83a9733881d05ULL, 0x66da5927d3cac1a4ULL, 0x2064726c37f70452ULL}, 
        {0x0ecc18678805118fULL, 0x021b23c3f24aa491ULL, 0x37573e489c068267ULL, 0x460669d6be9eb15cULL,
        0x26d5305de843511eULL, 0x04624c6a2731618bULL, 0x4f82574108485db2ULL, 0x1a7130991e33f4f2ULL,
        0x1ad3357d24d2c4b6ULL, 0x706f46d54a2763c0ULL, 0x7f0965abd07c9c85ULL, 0x5bc81a2a7cec2982ULL,
        0x130743dc0f21cf13ULL, 0x718824c342642cbbULL, 0x1460463875cc1456ULL, 0x5d130db098b9cc2aULL}, 
        {0x13b548e46e520d5aULL, 0x0f1673e7c0470ca5ULL, 0x3b3e51299b8780f0ULL, 0x58bd6a882e23dc98ULL,
        0x63a60bd25b18b3f8ULL, 0x47270a65a23d8625ULL, 0x6b1c0ad56affe655ULL, 0x53173cc1562f36e5ULL,
        0x02a70636a69aee7cULL, 0x38ec2358539caa43ULL, 0x65b92429f066f29fULL, 0x0cd341a0e53cf97cULL,
        0x30080c7731514380ULL, 0x5f3b4b4f2c837d42ULL, 0x45994b227db35bdeULL, 0x05893c1dcee4e3f5ULL}, 
        {0x011d464c55e7f183ULL, 0x5b0d1ccbcfbe5186ULL, 0x1c814b55087e3ef6ULL, 0x0e3519647edbb4f6ULL,
        0x07c177443d1a4ec8ULL, 0x4e014cc38ea12972ULL, 0x21fd7e688de28385ULL, 0x6bb7655541d08b14ULL,
        0x08ce173f4b9b2a3dULL, 0x44d80720c4ed1b44ULL, 0x71da0c96685d39bdULL, 0x09520f049d4b4ab3ULL,
        0x42a63af274ec2a53ULL, 0x31f71b413dada9fdULL, 0x5aac7d2fc0aef748ULL, 0x3b2e7d3ab691f1e5ULL}, 
        {0x43ae4c67a24331e3ULL, 0x77e978798d142b39ULL, 0x3c491715dab93e25ULL, 0x10d772f2ad7e014bULL,
        0x50cd137a1367b50dULL, 0x03da7a8c78632514ULL, 0x764c11408562d68cULL, 0x37bb43ddfd6dddf3ULL,
        0x5bf10e5eba932814ULL, 0x781d06354bc3ad09ULL, 0x6693133b707032c8ULL, 0x6daf58dfe110263bULL,
        0x0a8a1a169e535547ULL, 0x66a675a34429cbd0ULL, 0x77c205a5936eca1fULL, 0x036b048fae5520afULL}, 
        {0x4c0e6afc3b66bbd8ULL, 0x1b9054f8e833d441ULL, 0x3fbe32b1858881a8ULL, 0x6f0927bb37440eeaULL,
        0x0073553ee29ff8bfULL, 0x77996ec86e0bd231ULL, 0x2e3236a6e86d0136ULL, 0x6e8a25e229df9475ULL,
        0x2eb8655c17c11c9dULL, 0x5aa128a01645dc54ULL, 0x4b0d4060bd2f1f2eULL, 0x3a5129b8700316a7ULL,
        0x4b5c48abf4641498ULL, 0x1e2f2f7c8dbf7a1eULL, 0x050221cdcb21356fULL, 0x47a639a594491986ULL}, 
        {0x0ee505d586d0043cULL, 0x1fec74504e8207a0ULL, 0x1007307100ba882bULL, 0x1b341c4619e2a4a7ULL,
        0x5c5b055630e1a85cULL, 0x5c267880fea10b6aULL, 0x53d775e2cc73a5cfULL, 0x2b8c0cebe07b9a0dULL,
        0x37ca6a0009e6b6f3ULL, 0x184e6a68d11ba06aULL, 0x6a70304d83a8c1d9ULL, 0x53a04017861c240aULL,
        0x4cc339793c7f3a00ULL, 0x1d7a11d5e7b7d2ccULL, 0x2e9522efbf771ac3ULL, 0x55483803c405071dULL}, 
        {0x04dc54b8687ffb6aULL, 0x02e40c8aaae8fbdcULL, 0x5a4d369cbf9f56daULL, 0x6bc1691bd2920cd5ULL,
        0x2e2c408b03cdd8dfULL, 0x08695abc35ac28e4ULL, 0x35626a3cc565e321ULL, 0x6e292e80c11b59b0ULL,
        0x31d03e14b44027b1ULL, 0x010a3b95ab6b730cULL, 0x53e31349796d5a35ULL, 0x02040e84e1d1d9f8ULL,
        0x5a683347ba8318bcULL, 0x4d6f59b59ed76b3bULL, 0x64a26e53449fda27ULL, 0x5dba4f321d9f92a8ULL}, 
        {0x2a9a636e46f4133fULL, 0x665f47ac6ccc6bf7ULL, 0x0fb77f7cb9076b5eULL, 0x1b165ac35f0b1048ULL,
        0x438e77a5df8218c2ULL, 0x774a4c82a0330342ULL, 0x64fb42fcebb05e7aULL, 0x19c97429e916bbd0ULL,
        0x5b71575ebf9021f3ULL, 0x08bf003051de4f80ULL, 0x5a8e2d9dd38bac2eULL, 0x71e53b88bf1b3e85ULL,
        0x43f350de36d17f86ULL, 0x3af6382481675f51ULL, 0x5b527d40b04a5727ULL, 0x766302b8fcafe5daULL}, 
        {0x00c811bf072e3d16ULL, 0x104743c181179174ULL, 0x656e59576240c9e6ULL, 0x479d71c53d83f953ULL,
        0x6e2b6f6ccba07b03ULL, 0x47b178dc4ebff6a8ULL, 0x38cc4369d14635a3ULL, 0x75d47b6ff6422961ULL,
        0x77567fa84f14d755ULL, 0x47541040f09aad88ULL, 0x159a57924894f72fULL, 0x33ab21aadc70de43ULL,
        0x5d0b0107f348c29bULL, 0x16f7522bdc2f4770ULL, 0x0acd5d00d7a6f2cdULL, 0x18aa0a1f3f4da8e7ULL}, 
        {0x0c0e13720fadeacaULL, 0x6a8312ce56302558ULL, 0x54992676b11bf21bULL, 0x73bd62a969b492caULL,
        0x03a840a84c47921bULL, 0x3c867ed1ca56dab9ULL, 0x4afa42cc8f940ce9ULL, 0x2db215d905f88bd7ULL,
        0x4c2654b8098df8f2ULL, 0x78b137cd35488669ULL, 0x602f7d6e0e95fe23ULL, 0x3bbe4f7378c9c247ULL,
        0x7d580688b946b1b6ULL, 0x365a40d07e773d7cULL, 0x2f3a2ed90f638da6ULL, 0x21f950ee42110583ULL}, 
        {0x55137051446f0cb6ULL, 0x02fb3addd8fd6226ULL, 0x1a615d211ae7e729ULL, 0x05dd15f863d32300ULL,
        0x5db0582067156e08ULL, 0x3cb1716924800899ULL, 0x79b02c6db88c0318ULL, 0x50cb48f0b40f4d25ULL,
        0x248a48561239b766ULL, 0x7cbe36e0500f54e4ULL, 0x59741f79d81f0176ULL, 0x6287076a4e9d7324ULL,
        0x00847829cbac9e13ULL, 0x1207111db305dad8ULL, 0x48c128142fb189bcULL, 0x53b776aee411a5e0ULL}, 
        {0x688004220cf514b7ULL, 0x0b9735f576e700e1ULL, 0x37ee07a0937329bcULL, 0x48672839259976c9ULL,
        0x59e9769da22ba143ULL, 0x531a57ade9455beaULL, 0x67147f94639bbd7aULL, 0x52884e3a20de57beULL,
        0x4f2a204c11d8c5cbULL, 0x5763417fec97113fULL, 0x649251fdde41c313ULL, 0x646c40179de3faedULL,
        0x463440b4f0d95b6cULL, 0x46e6441a4a223968ULL, 0x1b8c11f88a3ec79cULL, 0x534b4ee681e5b3b2ULL}, 
        {0x56fc7eae4b3ef428ULL, 0x5a3f721f1cd63a0cULL, 0x7267443a920fbbffULL, 0x69c269f4303dd478ULL,
        0x59fb30e702283cc9ULL, 0x2ea92ca4252b2bd2ULL, 0x794e4f8924b359dbULL, 0x0a4f1341e73d1396ULL,
        0x1ead76612baa54beULL, 0x30887fb53706363dULL, 0x28b13d40d48b8567ULL, 0x61d624022213e236ULL,
        0x32121eef6dad39feULL, 0x15e04ece8f95f290ULL, 0x2fc049cff83baa51ULL, 0x2a1f611ef8a5d72dULL}, 
        {0x353063bd68c91ee4ULL, 0x68db51623830c8acULL, 0x52f445380d8b1d9dULL, 0x7c565fb27f7708e0ULL,
        0x438f6fc60e2ad115ULL, 0x22475f57673b53f2ULL, 0x5a87439313427b86ULL, 0x3389398d26846a21ULL,
        0x69bc385c056f155aULL, 0x54150d87df05bc20ULL, 0x10f71d8bf00c085cULL, 0x5f2e11b41a243313ULL,
        0x2bc625a408870983ULL, 0x63db1a4151a41e32ULL, 0x518840dfcd581366ULL, 0x459a68dfa6e93c05ULL}, 
        {0x1bc40b1749978347ULL, 0x555329c6b8dde544ULL, 0x26bf50e2783552c4ULL, 0x768b41f9907e5a56ULL,
        0x004d7002cad37123ULL, 0x24da52ccbcfd2b6fULL, 0x78e716fcc4374348ULL, 0x6d9f16a47a8ac653ULL,
        0x0afe2806c4653a3bULL, 0x31f27aff12bb1dadULL, 0x4c8f4326e7548e5eULL, 0x44da1bb4448f7817ULL,
        0x1ef83b9906461e38ULL, 0x39c0037bdd1958b3ULL, 0x110a7c72dec263e7ULL, 0x772455af69c7896cULL}, 
        {0x275f20835125942cULL, 0x618f4553094549d7ULL, 0x7eed4180c9deda1cULL, 0x32c97d54610993acULL,
        0x7ddc4262bb41ae6eULL, 0x514b5e0db1778dedULL, 0x0695190a4c03536bULL, 0x3bf7341002a6109dULL,
        0x611c5b27104c747bULL, 0x5e074c247dcf5327ULL, 0x4e9f1259f071d958ULL, 0x5f44088adc49b955ULL,
        0x7b4f1b972d4b47d8ULL, 0x44785b85ff3ab9f6ULL, 0x426e15ce822b7c60ULL, 0x74254b199dd7ea17ULL}, 
        {0x78a923ca687543efULL, 0x7377621218502fe9ULL, 0x30a9055a76d4b7d3ULL, 0x6f7832487051ff37ULL,
        0x2de54bafe81499f2ULL, 0x66834c225430d38eULL, 0x79ba2d064195cdbbULL, 0x05fb4f595ab1b2f5ULL,
        0x4ebd3b870b64f4b8ULL, 0x103c78fe4d69d751ULL, 0x4e50036cbff529b7ULL, 0x5ed252bfa0cc8161ULL,
        0x34735465c274d89fULL, 0x54ea676607cfdb5eULL, 0x7ddd3a3b8ec1bfdbULL, 0x560520a221310839ULL}, 
        {0x344c68b4f205026cULL, 0x14f4320a54634f7dULL, 0x55191eb874e96b94ULL, 0x4f00355fb90c65c9ULL,
        0x060f44b1d66bc42aULL, 0x47695c113332d6f6ULL, 0x0c7d4a38b95b5284ULL, 0x17125a05a10095cdULL,
        0x3a8a06ed5d6c6d0bULL, 0x247a6d963030a36fULL, 0x46c922a68aed4165ULL, 0x57ee28dace0dd84eULL,
        0x420d48cd8b21a247ULL, 0x5ffd6026c01fd6ceULL, 0x1f7f2b0358350ee5ULL, 0x1a2d61d4526d0c85ULL}, 
        {0x02ed1709d6d5c1fdULL, 0x73ec5b43a968e416ULL, 0x496523e1396af78aULL, 0x57c90f20bb7210b7ULL,
        0x00033a308be64011ULL, 0x7ae440e45b02f048ULL, 0x3d077be749470391ULL, 0x1ea3799e736d241aULL,
        0x0f2a4f222ba40f11ULL, 0x1aa709f3534d2f45ULL, 0x7733105106eb61ceULL, 0x42ff6d63238649b1ULL,
        0x1fc52f95cc32f60dULL, 0x7e9b72ce7af245acULL, 0x477b3d6db4b4c988ULL, 0x22034e360da19f2eULL}, 
        {0x11372a917765f37eULL, 0x624977c686c6a6b9ULL, 0x2eb63f1eba27dc61ULL, 0x743b7c13723bc8d3ULL,
        0x19680cf48ba5a024ULL, 0x2bde21a35aa9fa29ULL, 0x4d7f615c07c7822eULL, 0x301807acef4f464eULL,
        0x3b4679ef1acb8de4ULL, 0x16ad221d64667616ULL, 0x62b500b369fc4cddULL, 0x7c6d36e2dc2ddc9cULL,
        0x4d4213864d06a5abULL, 0x6dab4064008f40d9ULL, 0x59f95ac0f8f0d451ULL, 0x32f05950b065ebeaULL}, 
        {0x0fcf7314bdb4894bULL, 0x55f1159ad764d0e9ULL, 0x6a342eb76d701d44ULL, 0x72bf6cc15d9fd871ULL,
        0x53e771c4dd46f35eULL, 0x293e19543caf4ebcULL, 0x440e2de087cbf026ULL, 0x42d811b5b17c675dULL,
        0x3186411a50211722ULL, 0x60727e1d90a2f1a6ULL, 0x50783c1469b143feULL, 0x449f4fe0b87a1ba3ULL,
        0x4e2d5368517c015eULL, 0x0e145df3a2be62baULL, 0x7f230045fa188f4aULL, 0x765d2aab19d19ae9ULL}, 
        {0x336014590d41f440ULL, 0x68ce36c70aaa1ba9ULL, 0x250644f447153adeULL, 0x05bb05b179530966ULL,
        0x3528716a06e9cc39ULL, 0x65ec37019019c4a3ULL, 0x6adc28b9e1c2f0c4ULL, 0x324b5943d84d6fbaULL,
        0x6891326b736560e4ULL, 0x63e059fa86ab9937ULL, 0x4ba31ebe3b19071dULL, 0x3fff36e5f36510d9ULL,
        0x2a2d22039ff5dce1ULL, 0x64c054802cc6c431ULL, 0x231f3f4410dadc00ULL, 0x79b01dcea47dd5e2ULL}, 
        {0x349006294b0c26b7ULL, 0x58c651560d7ebf7dULL, 0x4c55681cbe64355cULL, 0x43991f6b4291a503ULL,
        0x46d268ac0b2f3db2ULL, 0x78cf7db16371b803ULL, 0x50102d2fa89ba2d5ULL, 0x3dd953dd0098c75aULL,
        0x5b102faca7d798c7ULL, 0x30de65bc72a6e98eULL, 0x235f18f894c4daa5ULL, 0x76f41e774b6444d2ULL,
        0x6ceb061e7d4f8670ULL, 0x1a962115eb6fffa3ULL, 0x76153d040f671c7eULL, 0x2e534241307f4606ULL}, 
        {0x5007144cde94908cULL, 0x07c34f4e4d4a7868ULL, 0x11481279c72e9069ULL, 0x26bf4678b80f741dULL,
        0x168d08537236d645ULL, 0x1cd1646d42bd0180ULL, 0x45d32a8cf3c7a8a3ULL, 0x08ea2b0c47b75aafULL,
        0x07aa6ea3923671e6ULL, 0x7b53456c013bd9eeULL, 0x6ad42f09aac17d81ULL, 0x55e66d20fe6fc1a2ULL,
        0x260e5a83afead3c5ULL, 0x7c7e34b9ae012df3ULL, 0x6c2e32cf4b6e3050ULL, 0x69ac5b8d1a6f1509ULL}, 
        {0x466e5e8aabd9251cULL, 0x7bac0eb7b8f37eedULL, 0x69085251d8c24c30ULL, 0x0d973b5f5706c107ULL,
        0x36035527409daaecULL, 0x30d9563c3c86fa3cULL, 0x624c2416573524faULL, 0x1ae63c564b7f91adULL,
        0x710879195ac21dddULL, 0x1b2911116293e31aULL, 0x7929793a33a0321dULL, 0x2d3d3d67c8ff11dbULL,
        0x693f4df87ba6121dULL, 0x7b607475c142e884ULL, 0x3d916deb9c1e7b80ULL, 0x652561394065ed1fULL}, 
        {0x5c6d58ab185b5540ULL, 0x5e69619abae38a11ULL, 0x0cbc49ede6f0eb5cULL, 0x3a8772a81d2c5595ULL,
        0x3ad927effb854923ULL, 0x37d03226dcd27ddbULL, 0x7fa43117ea54b626ULL, 0x5f351946294955c8ULL,
        0x1dd22cd7a43a4dc6ULL, 0x0c4754b342540057ULL, 0x698723d36470bb65ULL, 0x31625dd4e9093b93ULL,
        0x4e266346a7e21632ULL, 0x2c243950f37a483aULL, 0x66684fa15628de9aULL, 0x3e247ecdfef8f8fcULL}, 
        {0x5aab4a7609191156ULL, 0x7de10dfe43ffd757ULL, 0x798d2f9567066e1aULL, 0x53f914dc87ba791aULL,
        0x3eba2d75a98dc6e6ULL, 0x589c4b333229e181ULL, 0x3c027cd5401481f2ULL, 0x253f07617feb10f3ULL,
        0x18af3ba297dd333eULL, 0x6e95105acea6ab67ULL, 0x1b156f1cf2c058c4ULL, 0x7abb50f01c07cc5bULL,
        0x706a7135777e3041ULL, 0x47b350529071e878ULL, 0x26d84d394fbab9aaULL, 0x761313d23340ded2ULL}, 
        {0x0dd14fb4e592cd37ULL, 0x4bfe4debbeb01ec2ULL, 0x70a34d9150d45615ULL, 0x64547e829365f76aULL,
        0x5f4c667fcfd4b2b0ULL, 0x5e26686ccb9202d1ULL, 0x798f469971e426a9ULL, 0x206d00316abfaba2ULL,
        0x70472b45d66c8060ULL, 0x05fb380fb430dc8eULL, 0x30fc2f5c13a1cc25ULL, 0x05b14d42a0efca47ULL,
        0x6fb4228cb3d83105ULL, 0x2af37a83676fe122ULL, 0x030b6ffbdc84f03cULL, 0x725933cf3cd5c956ULL}, 
        {0x4686582d91c77841ULL, 0x5ea74f691ade98d6ULL, 0x7725022816aba577ULL, 0x5a004022be6719d8ULL,
        0x3e3727d672fa1d7dULL, 0x375644d8b39639eeULL, 0x5e7261aa10b4c718ULL, 0x6825313d889a90c7ULL,
        0x37435586882666c8ULL, 0x3a6133d9221a0d8fULL, 0x12634cdd7da157f4ULL, 0x32ad3d533239c1ebULL,
        0x6fab76159fd16cbaULL, 0x56cd6cecc43bcc9cULL, 0x4329552fd3b6e35aULL, 0x7c5e264cf6cd62baULL}, 
        {0x597327a97335844eULL, 0x6fc43481c5effe96ULL, 0x563b3fa3b059deeeULL, 0x07651e450777a838ULL,
        0x01241a42181e9bc7ULL, 0x77150f7f793b5f7dULL, 0x54d4355234f30489ULL, 0x77d07c0df5d5a8d8ULL,
        0x044b682f53ca9691ULL, 0x17af5fc1c40c38afULL, 0x6a7343e564d0bc1dULL, 0x46153fa910dcba5bULL,
        0x17f83e9600c8b11aULL, 0x70295094761bc3c9ULL, 0x73592e1c8afe7391ULL, 0x418a66d1bfc0d4b3ULL}, 
        {0x1f4055f070dee4b9ULL, 0x5d3e133aabcb8b86ULL, 0x1b0f0c4a932d00a3ULL, 0x22eb1172e9ccedddULL,
        0x51bb3a8ac6e03c8cULL, 0x54496b6a2a09cda0ULL, 0x0add3cd7729100c8ULL, 0x2ed7762a51465ec6ULL,
        0x720665065b974156ULL, 0x4dcd0bcec92dd5b0ULL, 0x285324bd7fbe3c0bULL, 0x685226cef6513e2aULL,
        0x144222d81d9d5262ULL, 0x3ff04283cad95f0cULL, 0x63c4400bd58d03ecULL, 0x534524e774c6c773ULL}, 
        {0x74944ec9ed40085fULL, 0x28fb759d3adaf8a9ULL, 0x16c60265b4f98e44ULL, 0x46fa4631631db29aULL,
        0x5da3597802609246ULL, 0x29db6fa053085efbULL, 0x72b40782e0fd5c21ULL, 0x50a0691bb8479906ULL,
        0x1f1d21d4474e1a33ULL, 0x30a37c08de24dfd6ULL, 0x7f2d13ad037a98a9ULL, 0x25cd794a238d576bULL,
        0x14321da3baaf214cULL, 0x330853c28cbbba48ULL, 0x289264440b1274f6ULL, 0x26f74415747665afULL}, 
        {0x3a1751fed05be29bULL, 0x78e459b05f037e83ULL, 0x5e8b503c880a88fbULL, 0x71fa1d0af3a341c4ULL,
        0x56851bd2d23caef0ULL, 0x76b4272903be6ab3ULL, 0x4282389b13273a5fULL, 0x04955268c7adc58bULL,
        0x2e3748603b2d51c4ULL, 0x381a68773019cfe4ULL, 0x662648fca6941263ULL, 0x6eed71a355098db3ULL,
        0x4b707dbe1ede6f15ULL, 0x5a5b09580c886ee3ULL, 0x19ea080f00bd26bbULL, 0x16085be49be8589aULL}, 
        {0x547273557fafe348ULL, 0x16e1317d89aed717ULL, 0x4b84381706307273ULL, 0x06532a869514622dULL,
        0x72087a61ba952207ULL, 0x5dba110ec635cc69ULL, 0x746e076a207e3aceULL, 0x561d639a9dd0c9c8ULL,
        0x45fd5674def59924ULL, 0x00187d246db39f1fULL, 0x186810f49c1b6c24ULL, 0x18197e63c7bdec13ULL,
        0x71a365f30d880d78ULL, 0x6ad05c4d168993beULL, 0x53f42cb40b3dfdc6ULL, 0x5de037db46b4c9e7ULL}, 
        {0x2c4d1a97df3bfdc1ULL, 0x70db630ca4c23ce9ULL, 0x7ad9103da2bc4cd9ULL, 0x4a6d372cc8a8602aULL,
        0x69d541edc109ff85ULL, 0x25d72056a9f2dc42ULL, 0x46a13f369ef27f39ULL, 0x349f0238d68911b2ULL,
        0x11171dd654e422efULL, 0x48865a16c21bc849ULL, 0x151b4bdb9c9fe659ULL, 0x59bb42113920fc21ULL,
        0x42734d08cd8f4db0ULL, 0x3d4e39aaf785c43dULL, 0x36da677a00c15923ULL, 0x1fe7578255f062caULL}, 
        {0x2e4f038c557ea2e3ULL, 0x18b848631fa666fcULL, 0x4db342f7537b97d7ULL, 0x68b03f848817048eULL,
        0x7b93133e6cb9d7e6ULL, 0x39f23c093cfe74e1ULL, 0x3b433f49a1f3aaebULL, 0x738547ca912e85bbULL,
        0x3e2c444f44bb9e3fULL, 0x754d1355ddf643a6ULL, 0x1f666dfadb2f43ecULL, 0x503a1336e829c6efULL,
        0x7d8a7dc62450017aULL, 0x4ebf02767ec31a44ULL, 0x66c161ab36f91b5eULL, 0x61866e6123344bf6ULL}, 
        {0x4b213dfbc878c209ULL, 0x44622f8ce64390d4ULL, 0x693a4e8d8ebf5599ULL, 0x6f857417549897abULL,
        0x68eb631bc043bb26ULL, 0x28f33f308ae0ee69ULL, 0x187b7ae9bf6fdcb0ULL, 0x4a3601d86a988ed7ULL,
        0x7fe443a7d2b83fb1ULL, 0x0e5330eaeb6e8af9ULL, 0x3e727f990e5ac349ULL, 0x7bfe7c599050d511ULL,
        0x668d16f557ac7a0fULL, 0x400a0bb9f70b2e37ULL, 0x4bd3588d8215a681ULL, 0x0c2364018e982f9fULL}, 
        {0x776b2dad9ca8d00eULL, 0x4dbf5a8f67007374ULL, 0x36954547475608ccULL, 0x5152396c29e3e456ULL,
        0x77857a4d44c83dc0ULL, 0x25c178d222a0237fULL, 0x6871795f0ed6b8d4ULL, 0x541a31eb801c177aULL,
        0x0ce969a6a59bb660ULL, 0x3f822edc9b299787ULL, 0x3d671d006c31295bULL, 0x416f3c02708c319aULL,
        0x45270b5d2b028a2dULL, 0x56171e7b31a41af9ULL, 0x12381d6939c4da18ULL, 0x6d2853e9f5b33879ULL}, 
        {0x2bd40a6bb70ebd4eULL, 0x32b97f7290c34860ULL, 0x62ed4d6cf690b199ULL, 0x6480280c842e32e3ULL,
        0x7108759dfbe76eb0ULL, 0x07462bf711c46c45ULL, 0x794e55f323185d23ULL, 0x10990d8a6f948996ULL,
        0x1fe05814e2a535e8ULL, 0x58c17d33194fe312ULL, 0x2b6c7676a842b68fULL, 0x68f544ba4655651fULL,
        0x64fe21c5e731810eULL, 0x79ce77c5785678edULL, 0x2a18158631351a30ULL, 0x35fb0da1349d0db6ULL}, 
        {0x65045ffb7e2afaa4ULL, 0x1537483fcef6c99bULL, 0x5f6921468e3cd2aeULL, 0x63780c7d62334d24ULL,
        0x231d45d06dbfe171ULL, 0x48690fa7e456a460ULL, 0x5d3a3fec13a56fe6ULL, 0x631b7e3e5556cda1ULL,
        0x777404b82d936d63ULL, 0x4df77ff8128867deULL, 0x5ba95044fa9d2bcfULL, 0x1ef83d074da279b2ULL,
        0x15ba74f7509a326eULL, 0x3817489e9b6860f7ULL, 0x479a3a2ec0194653ULL, 0x7c0614b2a9edda0aULL}, 
        {0x23a40e25d8fb796cULL, 0x3b2052fe0f7e2fa9ULL, 0x61320f1b87ab6c34ULL, 0x6ca1674942277d6dULL,
        0x5f6b2fb19ef0a5ffULL, 0x08124eebaadb24f2ULL, 0x6a5c7a94756b0febULL, 0x1308218ed03a4d8cULL,
        0x564b395baea6906eULL, 0x370e0f32b5fa9dafULL, 0x654702b316d2ca87ULL, 0x73e07f7445ecf7e6ULL,
        0x2b0473b9ab1bef88ULL, 0x41da360fe7a26d7aULL, 0x62e618a7ba9dc18dULL, 0x38af20a331bb48aaULL}, 
        {0x6c5c48b32900ac81ULL, 0x0e5e31b5c0c4348dULL, 0x616f7934d4aa00d8ULL, 0x02626cf721c38c93ULL,
        0x7b9b4c07139a4dd5ULL, 0x092908caef5cc49fULL, 0x3add5d315ddadd7dULL, 0x4bc84902fd98f3ccULL,
        0x030d13c5099d4f25ULL, 0x4fed76e9af4e7fc7ULL, 0x236e7a0932f154a2ULL, 0x5c151a866a28e9d1ULL,
        0x7c8460d4bd148719ULL, 0x6bff591f284cb85aULL, 0x3825523a75736b69ULL, 0x49601cfc2b9f7f47ULL}, 
        {0x47d3176b573a843fULL, 0x1cd86a6eceb011cbULL, 0x1d4955d9ec8b91c6ULL, 0x0b2506107c3ec4e7ULL,
        0x51540799d45bebefULL, 0x3297504dc160df8bULL, 0x2ce4530c61e3fc66ULL, 0x1cc37a227a472754ULL,
        0x486305be64b8dc21ULL, 0x787c77252eab86ebULL, 0x3545368e04870b8dULL, 0x2fff50c77bd0d904ULL,
        0x65e15310cc654e5aULL, 0x2f6e3ed6ae2cdafbULL, 0x477f1c2fc8caa7f3ULL, 0x6f80294672af2b17ULL}, 
        {0x42b25617c8267282ULL, 0x18767730a8a88066ULL, 0x15e82f52c51c9fa8ULL, 0x51514f1b5150ed3eULL,
        0x3e3f233064530fc7ULL, 0x0f422c7badee4f59ULL, 0x629a5b6d97f30df3ULL, 0x79626e77649ed398ULL,
        0x74f5550e64b7e780ULL, 0x34a343efdeb8ab5fULL, 0x7df54c8cc1a6b131ULL, 0x2c0618beb4dacf93ULL,
        0x46c335349f6d1409ULL, 0x290f683c458bed3fULL, 0x551b3fce075055b6ULL, 0x50771907668373cbULL}, 
        {0x6da0347d60c668a4ULL, 0x572046043a94bae2ULL, 0x107323e6d3ad2caaULL, 0x034e18a01e3052ebULL,
        0x24033394c923cc5bULL, 0x4e13185cc28f6c2dULL, 0x4227099b94fb31f0ULL, 0x390b13885975628bULL,
        0x5b6a1b7c2ed8a4ddULL, 0x2c4a054eed9d69e4ULL, 0x24a564491edd86fcULL, 0x70931cf3d3be5513ULL,
        0x02d4460a790c2c60ULL, 0x19ca4a5a3a2f8a8bULL, 0x69221a5e0736d8beULL, 0x75ac73cae3330299ULL}, 
        {0x5d4636668798d781ULL, 0x52be38f0f2dc7942ULL, 0x161265de0c0dba78ULL, 0x33836728df96bcc2ULL,
        0x6849218d8ae8b224ULL, 0x41f202f88b4910aaULL, 0x75b204e06e6b0aa6ULL, 0x17270add7623bba0ULL,
        0x526a46d269dbc352ULL, 0x2b59574b0a02b7c0ULL, 0x147e3a0e513b4dd9ULL, 0x020c3bef15737596ULL,
        0x01b9185821a0661bULL, 0x66884e375c60cbc2ULL, 0x4fbb1d291f2b1096ULL, 0x4c89751447560133ULL}, 
        {0x2a4b3399209cb176ULL, 0x293825ffbe67f60aULL, 0x73ef3b82e68c4a3eULL, 0x585a733a12b87516ULL,
        0x74b929e3ab44d41fULL, 0x61c84f5818a494f3ULL, 0x6b630882ba31bae3ULL, 0x331f29ff58814accULL,
        0x349f18d63a00757cULL, 0x21b849ed600d11b5ULL, 0x7ca81e23104f4632ULL, 0x48db08393971b8b0ULL,
        0x2f1d12e7dc0b1375ULL, 0x182f50dbf7e74a47ULL, 0x190f4d75245f604bULL, 0x26750c6f700419cdULL}, 
        {0x715957e09252685cULL, 0x1c7657360b9deb3dULL, 0x3b2f7f1a57fa5ea6ULL, 0x4c3a295eb55045bbULL,
        0x36fa5d5db155c2c8ULL, 0x487b5483f6a7d3adULL, 0x556363ca8dbee2f2ULL, 0x10597a751ee5f781ULL,
        0x60ae275146066c76ULL, 0x2350613c9f677007ULL, 0x504a74d08f2a34f4ULL, 0x116648597baf2874ULL,
        0x7aa6707f70aa072aULL, 0x5ba9234fda0a1ffeULL, 0x1946448b6b80a866ULL, 0x38d85d62bad4751aULL}, 
        {0x53152301c1b8ec90ULL, 0x12610a9fc765925fULL, 0x40fd1eeed3a5f6dcULL, 0x4d8b2a1c46937704ULL,
        0x20b520c5a4ba8f19ULL, 0x34f55d8131db26faULL, 0x29da7a007d00a39eULL, 0x163f39c765272bb3ULL,
        0x39425c0ab32ddadbULL, 0x68071540f3374c7aULL, 0x468d365d855a5889ULL, 0x0c1776d89aa64e77ULL,
        0x57fc3fe7225e9176ULL, 0x01dc0a9a5190e54aULL, 0x68872fb3cabf4af5ULL, 0x1d1b3f7604debd4eULL}, 
        {0x742968c5154fb0eeULL, 0x14df72415e27a374ULL, 0x1e7f1d46505e968cULL, 0x7eb649fdc13ad4c4ULL,
        0x27912ce10794cc8eULL, 0x0a1c295b5846657eULL, 0x22f0426ca0689f32ULL, 0x1038597e499fd1d5ULL,
        0x250174cb263471c8ULL, 0x4bc652020a25a051ULL, 0x5a986f1127f073dfULL, 0x4d55423dd14b34cbULL,
        0x3ec863e9b7868514ULL, 0x7fb23fc42bc2b50fULL, 0x62fa503596cb2982ULL, 0x50a43e31abb91b1cULL}, 
        {0x7d3d50f47116a5d0ULL, 0x51d93424c0ca58feULL, 0x30dd106944743de2ULL, 0x66211188a57ca550ULL,
        0x45370e7ae0828a23ULL, 0x4eda6b187871ec5dULL, 0x3ecb48568be4f87aULL, 0x2dab7f216a2452dcULL,
        0x0e93035ac55a61d7ULL, 0x4e7677891157e54fULL, 0x4b943f362a7ac75fULL, 0x4d870d10e0186303ULL,
        0x2ab2134b7602323fULL, 0x6e126fd6b56728b1ULL, 0x28c87b58a6d4a419ULL, 0x34dc191e8d7d39b8ULL}, 
        {0x1af857563c8d3d13ULL, 0x1b386a5158b56b01ULL, 0x194022a0a4b66e88ULL, 0x6e353d46ef11b47bULL,
        0x774e2657b6a35b53ULL, 0x2e1649c01f61923aULL, 0x3f962b0554e54ec2ULL, 0x02020438e30d973aULL,
        0x64a16d8036605c24ULL, 0x13fd59ddb67615b8ULL, 0x1ca85b12c50816f5ULL, 0x69176dda0403e534ULL,
        0x1b6158d623306ab3ULL, 0x09e33bd7bbc65912ULL, 0x1e191a654d899e45ULL, 0x0f2b43c206c140d5ULL}, 
        {0x7e034bb25bb26811ULL, 0x66e222cf15d11501ULL, 0x3cd01233e6742aaaULL, 0x655a3dbd1b304b97ULL,
        0x3f7f29428c98501aULL, 0x76b8605c59a0b239ULL, 0x2b771dc29059c5d5ULL, 0x04a4764c54320ae4ULL,
        0x19d36d059d85944bULL, 0x6445410727a8a850ULL, 0x14fd0aedac2aa00eULL, 0x606c2f21f98443f2ULL,
        0x147e135205f180abULL, 0x340f38cf8da6df97ULL, 0x6b142aa462197912ULL, 0x08fa65a7f49dd9a8ULL}};

const CACHE_ALIGN hash_t ep_codes[64] =
{
    0x6c207454dd4a2536ULL,
    0x597a1167bcfe4976ULL,
    0x4d664169967d2a3fULL,
    0xb4df7b56eae21a1bULL,
    0xf03a2e053e9521c3ULL,
    0x6528cd993bcc67dcULL,
    0x40411f06b12275c3ULL,
    0x1ea5e41cdf3f3ce4ULL,
    0xf6ac5035048ff225ULL,
    0xe59e43dd4c87c6e3ULL,
    0x318b6b9d0b7c537bULL,
    0xb19e1d45410a71e6ULL,
    0x7d9792d674865060ULL,
    0xec436970db9068a5ULL,
    0x6a897756521db13dULL,
    0x0f0f73802622b2d1ULL,
    0x976364c0ab4edf1eULL,
    0x25bae970284bbfe5ULL,
    0x4744cdb88b187101ULL,
    0x67016de0f5eff2f6ULL,
    0x6d38e6af94bbbd28ULL,
    0x48f22264431e3708ULL,
    0x3c0829340d076966ULL,
    0x02c1c15aee5b914fULL,
    0xb806ed42722afaf0ULL,
    0x2898a6b39575ab93ULL,
    0x4be3f697840664adULL,
    0x3761de49a05267f3ULL,
    0x4afd847cda791a09ULL,
    0xa71fbcaa58c0ed38ULL,
    0x8f2d5e1970b59e3eULL,
    0xf7b5e46cef47bea4ULL,
    0x84966845b60a14abULL,
    0x41be5f799a744345ULL,
    0x35fab353a4b94ba1ULL,
    0x445727e3962fd7c3ULL,
    0x5e890be7c4c45533ULL,
    0xfe72bcb4c008e330ULL,
    0xfe2a03434a3c1184ULL,
    0xb424af39a0046458ULL,
    0xe455101418133d9eULL,
    0x8278b755fef5fc91ULL,
    0xc05b8dc85ae9083aULL,
    0x713c3bd46f438b8dULL,
    0xb53cd4dc14639f93ULL,
    0x0054e5b6e13e3126ULL,
    0xe471462b2872bfb8ULL,
    0xb986b784366e6832ULL,
    0x8443e23a73294459ULL,
    0xbfce131bc7659350ULL,
    0x68955392d40bb919ULL,
    0xde2bcc7cfe8b0bb8ULL,
    0x98b6fd08435be8dbULL,
    0x1def3da4e2f2ae92ULL,
    0x5c33918c59eb6c99ULL,
    0x4996d052a6a4f4b9ULL,
    0xcd221b836773bb2bULL,
    0x0a8a175cbbf17d96ULL,
    0x66fa8f0b81d2401cULL,
    0xf07bd180ddc51f6dULL,
    0x915a63d113ef627aULL,
    0x88ae07b0aa72732bULL,
    0x3e6012e36c009626ULL,
    0xe44d10652981f134ULL
};

const hash_t w_castle_status[6] =
{
    0x85f1af3aaa504b75ULL,
    0xc9a1e5942f5e4cdcULL,
    0xdd3b5d06f7548d85ULL,
    0xd62f296d208bec0cULL,
};

const hash_t b_castle_status[6] =
{
    0x21972535ec9936ddULL,
    0x8a0fc3066cfd4750ULL,
    0xbb01866ba905e867ULL,
    0x021c4564829a7b92ULL,
};

hash_t BoardHash::hashCode( const Board &board)
{
    hash_t h = (hash_t)0; // hashcode
    Bitboard pieces(board.allOccupied);
    Square sq;
    while (pieces.iterate(sq)) {
       h ^= hash_codes[ sq ][ board[sq] ];
    }   

    Square epsq = board.enPassantSq();
    if (epsq == InvalidSquare) 
      h ^= ep_codes[0];
    else
      h ^= ep_codes[epsq];
    h ^= w_castle_status[(int)board.castleStatus(White)];
    h ^= b_castle_status[(int)board.castleStatus(Black)];
    h = BoardHash::setSideToMove(h,board.side);
    return h;
}
        
hash_t BoardHash::pawnHash( const Board &board, ColorType side)
{
    hash_t h = 0; // hashcode
    Bitboard pawns(board.pawn_bits[side]);
    Square sq;
    while (pawns.iterate(sq)) {
       h ^= hash_codes[ sq ][ (int)board[sq] ];
    }
    return h;
}
        
